gdbstub: Small fixes.
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 12 Aug 2009 13:27:52 +0000 (14:27 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 12 Aug 2009 13:27:52 +0000 (14:27 +0100)
 * Correctly handly EFLAGS.TF in the hypervisor
 * Register value sent with 'P' command is in native byte order.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
xen/arch/x86/traps.c
xen/common/gdbstub.c

index f0d261b9e950dd53502e94ab88e56d2a97b1d979..508cd9d3065d745400a3445a4190aa2ccc5fd750 100644 (file)
@@ -3007,9 +3007,12 @@ asmlinkage void do_debug(struct cpu_user_regs *regs)
             if ( (regs->rip >= (unsigned long)sysenter_entry) &&
                  (regs->rip < (unsigned long)sysenter_eflags_saved) )
                 goto out;
-            WARN_ON(regs->rip != (unsigned long)sysenter_eflags_saved);
+            if ( (regs->rip != (unsigned long)sysenter_eflags_saved) &&
+                 !debugger_trap_fatal(TRAP_debug, regs) )
+                WARN_ON(1);
 #else
-            WARN_ON(1);
+            if ( !debugger_trap_fatal(TRAP_debug, regs) )
+                WARN_ON(1);
 #endif
             regs->eflags &= ~EF_TF;
         }
index 6bbd23f395a08a48e5598e1fea587e45d951b64d..512172a1aaff2638e0263e5042b5933b97a346f9 100644 (file)
@@ -116,6 +116,28 @@ str2ulong(const char *str, unsigned long bytes)
     return x;
 }
 
+unsigned long
+str_to_native_ulong(const char *str)
+{
+    unsigned long x = 0, i = 0;
+
+    while ( *str && (i < BYTES_PER_LONG) )
+    {
+#ifdef __BIG_ENDIAN
+        x <<= 8;
+        x += str2hex(*str);
+#elif defined(__LITTLE_ENDIAN)
+        x += (unsigned long)str2hex(*str) << (i*8);
+#else
+# error unknown endian
+#endif
+        str += 2;
+        i++;
+    }
+
+    return x;
+}
+
 /* gdb io wrappers */
 static signed long
 gdb_io_write(const char *buf, unsigned long len, struct gdb_context *ctx)
@@ -488,7 +510,7 @@ process_command(struct cpu_user_regs *regs, struct gdb_context *ctx)
             return 0;
         }
         ptr++;
-        val = str2ulong(ptr, sizeof(unsigned long));
+        val = str_to_native_ulong(ptr);
         gdb_arch_write_reg(addr, val, regs, ctx);
         break;
     case 'D':